home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc51bugs.zip / Q37668 < prev    next >
Text File  |  1988-11-09  |  1KB  |  54 lines

  1. Q37668 _dos_setftime: File Must Be Opened as Read Only
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.  
  8. To use the _dos_setftime function to set the date and time to which a
  9. file was last written, open the file as read only. If you open the
  10. file with write privileges, the time and date are re-updated by the
  11. close function. The program below demonstrates the correct useage;
  12. however, it only works in DOS, not in the OS/2 compatibility box,
  13. where it gives an error message "invalid argument" and returns err =
  14. 1.
  15.  
  16. More Information:
  17.  
  18. The following code demonstrates this behavior:
  19.  
  20.  #include <stdio.h>
  21.  #include <dos.h>
  22.  #include <fcntl.h>
  23.  #include <sys\types.h>
  24.  #include <sys\stat.h>
  25.  #include <io.h>
  26.  #include <stdlib.h>
  27.  
  28.  main()
  29.   {
  30.     unsigned date = 0x421;
  31.     unsigned time = 0xC0F;
  32.     int fh, err;
  33.  
  34.     if (_dos_open("hang.c",O_RDONLY, &fh) != 0)
  35.        perror("open failed on input file");
  36.     else
  37.        printf("opend succeeded on input file\n");
  38.     err = _dos_setftime (fh, date, time);
  39.     if (err != 0)
  40.      {
  41.        perror("date and time not changed");
  42.        printf("%d\n",err);
  43.      }
  44.     else
  45.        printf("date and time changed\n");
  46.     if (_dos_close(fh) != 0)
  47.        perror("close failed");
  48.     else
  49.        printf("file successfully closed\n");
  50.   }
  51.  
  52. Keywords:  docerr buglist5.10
  53. Updated  88/11/09 05:51
  54.